package com.hoopeu.ui.widget;


import java.io.File;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.hoopeu.smarthome.R;
import com.hoopeu.utils.camerautils.Constants;
import com.hoopeu.utils.camerautils.ImageUtils;





public class HeaderView extends ImageView{
	Bitmap tempBitmap;
	public HeaderView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	

	
	
	public void updateImage(String threeNum,boolean isGray){
		try{
			tempBitmap = ImageUtils.getBitmap(new File(Constants.HEADER_IMAGE_PATH+Constants.Account+"/"+threeNum+".jpg"),200,200);
			
			tempBitmap = ImageUtils.roundCorners(tempBitmap, ImageUtils.getScaleRounded(tempBitmap.getWidth()));
			this.setImageBitmap(tempBitmap);
		}catch(Exception e){
			tempBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.header_icon);  
			tempBitmap = ImageUtils.roundCorners(tempBitmap, ImageUtils.getScaleRounded(tempBitmap.getWidth()));
			this.setImageBitmap(tempBitmap);
			
		}
	}
	
	
}
